<template >
    <div class="add_con_form tl" v-loading="loading">      
            <el-dialog  :close-on-click-modal='false' title="编辑留言"  :modal-append-to-body="false" :visible.sync="visible" :show="show" :before-close="closeDialog"  @close="$emit('update:show',false)"   class="tl size_13" width="800px">                 
                <el-form :model="data"  :rules="dataYZ" ref="data" class="mar_top"  label-width="100px">                 
                    
                    <el-form-item label="用户账号" prop="username">
                        <el-col :span="4">
                    <el-input
                        placeholder=""
                        v-model="data.username"
                        :disabled="true"
                        style="width:220px"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>

                    <el-form-item label="真实姓名" prop="name">
                        <el-col :span="4">
                    <el-input
                        placeholder=""
                        v-model="data.name"
                        :disabled="true"
                        style="width:220px"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>

                    <el-form-item label="电话" prop="tel">
                        <el-col :span="4">
                    <el-input
                        placeholder=""
                        v-model="data.tel"
                        :disabled="true"
                        style="width:220px"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>



                    <el-form-item label="时间" prop="created_time" >
                        <el-col :span="4">
                        <el-date-picker
                        :disabled="true"
                            :value="parseInt(data.created_time+'000')"
                        type="datetime"
                        placeholder="">
                        </el-date-picker>
                        </el-col>
                    </el-form-item>


                    <el-form-item label="内容" prop="content" >
                        <el-col :span="4">
                          
                    <el-input
                         type="textarea" 
                        v-model="data.content"
                        :disabled="true"
                        style="width:400px"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>

                    <el-form-item label="回复" prop="remark">
                        <el-col :span="8">
                    <el-input
                        placeholder="请输入回复"
                        type="textarea" 
                        v-model="data.remark"
                        style="width:400px"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>
                    
                <div class="mar_bottom_15">
                <span class="sizeColor size_13 sp_style"></span>
                <el-button  :loading='$store.state.isLoading' size="medium" type="primary" @click.prevent="addUpdate('data')">确定</el-button>
                </div>

                </el-form>
            </el-dialog>       
       
    </div>
</template>


<style lang="less" scoped></style>

<script>
export default 
{
    data() 
    {
        var checkTitle = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('标题不能为空'));
        }else{
            callback();
        }
        };
        

        return {
            value:"",
            data:{
                id:'',
                adminId:'',
                status:'0', 
                remark:'',
            },
            loading:false,
            dataYZ:{
                title:[
                { validator: checkTitle, trigger: 'blur' }
                ],
           
            },
            visible:this.show,
        }
    },
    props:{
        show:Boolean,
        editId:String,
        clickNum:Number,
    },
    methods:{
        closeDialog(){       
            //this.$refs['data'].resetFields();
            this.visible=false;
        },
        getDetails(id){
            var data = {};
            data['id'] = id;
            this.$api.getUser.getMsgInfo(data).then(res=>{
                this.data=res.data.result;     
                this.radio  = res.data.result.status;   
            })
            console.log(typeof(data)); //object
            console.log(data); // {id: 1, sign: "ca3ca63b05dafe8fe3ab8c719055b44c"}
        },
        addUpdate(formName) 
        {    
        this.$refs[formName].validate((valid) => 
        {  
        if (valid)
        {   
        var params = {};
        params['id'] = this.data.id;
        params['remark'] = this.data.remark;


            this.$api.getUser.MsgSaveEdit(params).then(res=>{
            if (res.data.code == 200 && res.data.result != null) {
                this.$emit("parent","这里刷新父页面");
                this.$fnc.alertSuccess({text:'编辑成功',});  //成功弹出框 
                this.visible=false;
            }else{
                this.$fnc.alertError(res.data.result);   //失败弹出框
            }
            })
        }
        });        
        },   
    },
    watch: {
        show(){
            console.log(this.show)
            this.visible = this.show;
        },
        clickNum(id){
            console.log("点击button次数",id);
            console.log("编辑ID="+this.editId);
            this.getDetails(this.editId);
        } 
    },
    mounted(){
        //this.getDetails(this.$route.query.id);
    },
    created () {
        
    }
}    
</script>
